package com.open.harmony.common.image;

import com.open.harmony.common.Result;
import org.springframework.web.multipart.MultipartFile;

public interface ImageDao {
    void init() throws Exception;

    void destroy();

    Result upload(MultipartFile file);

    default Result upload(MultipartFile[] files){
        int count = 0, fileCount = 0;
        if(null != files && files.length>0){
            fileCount = files.length;
            for (MultipartFile file : files) {
                Result Result = upload(file);
                if(Result.getCode().matches( "200")){
                    count++;
                }
            }
        }
        return fileCount>0 && count==fileCount ? Result.success("图片上传成功") : Result.error("图片上传失败");
    };

    Result delete(String md5);
}
